<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ADD USER</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    </script>
    <script>
        $(document).ready(function () {
            $('#addForm').submit(function (event) {
                event.preventDefault();

                var formData = {
                    username: $('#username').val(),
                    registrationDate: $('#registrationDate').val(),
                    email: $('#email').val(),
                    expirationDate: $('#expirationDate').val(),
                    membershipCardId: $('#membershipCardId').val(),
                    role: $('#role').val(),
                    weight: $('#weight').val(),
                    height: $('#height').val()
                };

                $.ajax({
                    url: `http://localhost:10265/wsn/add`,
                    type: 'POST',
                    contentType: 'application/json',
                    data: JSON.stringify(formData),
                    success: function (response) {
                        alert(response);
                    },
                    error: function (xhr, status, error) {
                        alert(xhr.responseText);
                    }
                });
            });
        });
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .addForm {
            margin: 80px auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }

        .box1 {
            width: 1000px;
            height: 50px;
            background-color: #ededed;
            border-style: solid;
            border-width: 1px 1px 0px 1px;
            border-color: black;
        }

        .box1 p {
            display: inline-block;
            font-size: 15px;
            margin: 15px 30px;
        }

        .box1 input {
            display: inline-block;
            position: relative;
            left: 860px;
        }

        .box2 {
            width: 1000px;
            height: 500px;
            border-style: solid;
            border-width: 1px;
            border-color: black;
        }

        .box3 {
            margin: 40px auto;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            align-content: space-between;
        }

        .box3 input {
            margin-left: 20px;
            width: 220px;
            height: 50px;
            font-size: 18px;
        }

        .box3 span {
            line-height: 80px;
        }

        .box4 {
            margin: 40px auto;
            display: flex;
            justify-content: center;
        }

        .box4 form input {
            margin-left: 10px;
        }

        .box4 input {
            width: 160px;
            height: 40px;
            background-color: #fff;
            border: 1px solid;
            display: block;
            margin-left: 100px;
        }
    </style>
</head>

<body>
    <div class="add">
        <div class="box1">
            <p>添加用户</p>
            <a href="Menu.html"><input type="button" name="close" value="X" /></a>
        </div>
        <div class="box2">
            <form id="addForm">
            <div class="box3">
                <span style="margin-left: 100px;">会员名称<input type="text"></span>
                <span style="margin-right: 100px;">注册日期<input type="text"></span>
                <span style="margin-left: 132px;">邮箱<input type="text"></span>
                <span style="margin-right: 100px;">过期日期<input type="text"></span>
                <span style="margin-left: 100px;">会员卡号<input type="text"></span>
                <span style="margin-right: 100px;">角色<input type="text"></span>
                <span style="margin-left: 132px;">体重<input type="text"></span>
                <span style="margin-right: 100px;">身高<input type="text"></span>
            </div>
            <div class="box4">
                <form name="form" method="post" action="#">
                    <input type="submit" name="submit" value="登录">
                </form>
                <input type="button" name="empty" value="取消" />
            </div>
            </form>
        </div>
    </div>
</body>

</html>